<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>报修详情-云校通-教师</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<body ontouchstart>
	<div class="weui_tab tab-bottom">
		<div class="weui_tab_bd">
			<div class="weui-header bg-blue"> 
				<div class="weui-header-left"> <a onclick="back()" class="icon icon-109 f-white">返回</a></div>
				<h1 class="weui-header-title">
					<c:choose>
						<c:when test="${isRepaire == 1 }">
							故障维修
						</c:when>
						<c:otherwise>
							故障报修详情
						</c:otherwise>
					</c:choose>
				</h1>
			</div>
	        <div class="weui_cells"style="margin: 0;">
	        	<div class="weui_cell">
					<div class="weui_cell_hd">
						<label class="weui_label"><i class="icon icon-106 f20 f-blue"></i> 故障状态</label>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<p><c:choose>
						<c:when test="${detail.repaireStatus == '000' }">
							<span class="f-green2">已维修</span>
						</c:when>
						<c:otherwise>
							<span class="f-yellow2">待维修</span>
						</c:otherwise>
					</c:choose></p>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd">
						<label class="weui_label"><i class="icon icon-85 f20 f-blue"></i> 报修人</label>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<p>${detail.repairName }</p>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd">
						<label class="weui_label"><i class="icon icon-104 f20 f-blue"></i> 联系方式</label>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<p><a href="tel:${detail.repairPhone }">${detail.repairPhone }</a></p>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd">
						<label class="weui_label"><i class="icon icon-51 f20 f-blue"></i> 报修时间</label>
					</div>
					<div class="weui_cell_bd weui_cell_primary">
						<p><fmt:formatDate value="${detail.repairTime}" pattern="yyyy/MM/dd HH:mm:ss" /></p>
					</div>
				</div>
				<div class="weui_cell">
					<div class="weui_cell_hd">
						<label class="weui_label"><i class="icon icon-69 f20 f-blue"></i> 故障楼层</label>
					</div>
	                <div class="weui_cell_bd weui_cell_primary">
                		<p>${detail.buildingName }</p>
            		</div>
	            </div>
	            <div class="weui_cell">
					<div class="weui_cell_hd">
						<label class="weui_label"><i class="icon icon-67 f20 f-blue"></i> 故障类别</label>
					</div>
	                <div class="weui_cell_bd weui_cell_primary">
	                    <p>${detail.repairType }</p>
	                </div>
	            </div>
	            <div class="weui_cell">
					<div class="weui_cell_hd">
						<label class="weui_label"><i class="icon icon-5 f20 f-blue"></i> 详细地点</label>
					</div>
	                <div class="weui_cell_bd weui_cell_primary">
	                	<p>${detail.repairPlace }</p>
	            	</div>
	            </div>
	            <div class="weui_cell xtbg-add-list-title">
					<div class="weui_cell_bd weui_cell_primary">
						<p class="f14">故障详细描述</p>
					</div>
				</div>
				<div class="weui_cell">
	                <div class="weui_cell_bd weui_cell_primary">
	                	<p>${detail.faultDesc }</p>
	            	</div>
	            </div>
	            <c:if test="${not empty detail.attachList }">
					<div class="weui_cell xtbg-add-list-title">
						<div class="weui_cell_bd weui_cell_primary">
							<p class="f14">故障图片</p>
						</div>
					</div>
					<div class="weui_cell">
						<ul class="imgClick" style="list-style-type: none;margin: 5px 5px 5px 0;">
							<c:forEach var="item" items="${detail.attachList }">
								<li class="weui_uploader_file" style="margin-right:0;margin-bottom:10px;position: relative;">
									<img onclick="imgClick1(this)" src="${config.imgUrl }${item.attachmentUrl}"/>
								</li>
							</c:forEach>
						</ul>
					</div>
				</c:if>
			</div>
	        <c:choose>
	        	<c:when test="${detail.repaireStatus == '000' }">
	        		<div class="weui_cells weui_cells_form">
			            <div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"> 维修人</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<p>${detail.repaireName }</p>
							</div>
						</div>
			            <div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"> 联系方式</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<p><a href="tel:${detail.repairePhone }">${detail.repairePhone }</a></p>
							</div>
						</div>
						<div class="weui_cell">
							<div class="weui_cell_hd">
								<label class="weui_label"> 维修反馈</label>
							</div>
							<div class="weui_cell_bd weui_cell_primary">
								<p>${detail.repaireReply }</p>
							</div>
						</div>
			        </div>
	        	</c:when>
	        	<c:when test="${detail.repaireStatus == '001' && isRepaire == 1}">
	        		<div class="weui_cells weui_cells_form">
			            <div class="weui_cell xtbg-add-list-title">
							<div class="weui_cell_bd weui_cell_primary">
								<p class="f14">维修反馈</p>
							</div>
						</div>
			            <div class="weui_cell">
			                <div class="weui_cell_bd weui_cell_primary">
			                    <textarea id="repaireReply" name="repaireReply" class="weui_textarea" placeholder="请输入维修反馈" rows="3"></textarea>
			                </div>
			            </div>
						<div class="weui_btn_area">
					        <a href="javascript:" id="btnSubmit" class="weui_btn bg-blue">确认维修</a>
					    </div>
					</div>
					<script>
						$(function() {
							$("#btnSubmit").click(function() {
								replySubmit();
							})
						})
						function replySubmit() {
							$.ajax({
					          	url : basePath + "/ls/fail/repaire/reply/submit",
					  	 		type : "post",
					  	 		dataType : "json",
					  	 		data : {
					  	 			repaireReply: $("#repaireReply").val(),
									id: "${detail.id}"
					  	 		},
					            success: function(data){
					            	if(data.code == '000') {
					            		$.toast("提交成功！");
					            		window.location.reload();
					            		return;
					            	}
					            	$.toptips(data.msg);
					            },
					            error: function(xhr, type){
					            	$.toptips("系统异常");
					            }
					         });
						}
					</script>
	        	</c:when>
	        </c:choose>
		</div>
	</div>
</body>
<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
<script>
	function imgClick1(thiz) {
		var obj = $(thiz.closest(".imgClick")).find("img");
		var src = get_img(obj);
		var currSrc = thiz.src;
		var current;
		for(var i in src) {
			if(src[i] == currSrc) {
				current = i;
				break;
			}
		}
		img_preview(src[current], src);
	}
	function img_preview(current, urls){
	    if(!current || urls.length == 0){
	        return ;
	    }
	
	    WeixinJSBridge.invoke('imagePreview', { 
	        'current': current,
	        'urls': urls
	    }); 
	}
	function get_img(obj){
		var m = [];
		for(var i=0; i<obj.length; i++){
			m[i] = obj[i].src;
		}
		return m;
	}
</script>
</html>